<?php $this->_extends('_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<link href="<?php echo $_BASE_DIR; ?>plugins/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/xheditor/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/xheditor/xheditor-1.1.11-zh-cn.min.js "></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/uploadify/swfobject.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>plugins/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript" src="<?php echo $_BASE_DIR; ?>js/la_common.js"></script>

<script type="text/javascript">
$(editorInit);
var editor;
</script>

<form action="<?php echo url('CommonArticle/add'); ?>"
        onsubmit="
        if (this.article_topic.value == '') 
        { 
	    alert('请输入文章标题'); 
	    return false; 
        }
        else if(this.article_topic.value.length > 255)
        {
            alert('文章标题不能超过255个字符');
            return false;
        }
        else if(this.summary.value.length > 1024)
        {
            alert('文章摘要不能超过1024个字符');
            return false;
        }
        else
        {
            var content = editor.getSource();
            if(content == '')
            {
                alert('文章内容不能为空');
                return false;
            }
            var images = $('img', content);
            if(images.length > 0)
            {
                this.content_image.value = images[0].src;
            }
            return true;
        }
	"

        method="post" name="mainform"enctype="multipart/form-data">

<label><h5>文章标题</h5></label>
<input class="input" type="hidden" value="" name="content_image" id="content_image" />
<input class="input" type="text" value=""  name="article_topic" size="77" width="200"></input>
    <div name="article_logo" id="article_logo">
    <label><h5>文章图片</h5></label>
    <input id="file_upload" type="file" name="Filedata" /> </p>
    <div id="filesUploaded" name="filesUploaded">  </div>
    <script type="text/javascript">
$(function() {
    $('#file_upload').uploadify({
        'uploader'  : '<?php echo $_BASE_DIR; ?>plugins/uploadify/uploadify.swf',
        'script'    : '<?php echo $_BASE_DIR; ?>plugins/uploadify/uploadify.php',
        'cancelImg' : '<?php echo $_BASE_DIR; ?>plugins/uploadify/cancel.png',
        'folder'    : '<?php echo $_BASE_DIR; ?>upload/article_logo',
        'removeCompleted' : true,
        'fileDesc'  : '图片文件',
        'fileExt'   : '*.jpg;*.bmp;*.png;*.gif',
        'sizeLimit' : 1024 * 1024 * 2,
        'onComplete': function(event, queueID, fileObj, response, data) 
            {
                while(filesUploaded.firstChild)
                {
                    var oldNode = filesUploaded.removeChild(filesUploaded.firstChild);
                    oldNode = null;
                }
                $('#filesUploaded').append('<img src='+response+' width=50% height=50%><input type=hidden value='+response+' name="uploadpic" />');
            }
    }); });
    </script>
<a href="javascript:$('#file_upload').uploadifyUpload()">上传</a>
</div>

<label><h5>文章摘要</h5></label>
<textarea name="summary" rows=5 cols=48 ></textarea>

<label><h5>文章内容</h5></label>
<textarea name="article_content" id="article_content"></textarea>
<input type="submit" value="发布" name="submit">
</form>

<?php $this->_endblock(); ?>
